package Main;
import java.awt.CardLayout;
import java.awt.Dimension; 
import java.awt.Graphics;
import java.awt.Graphics2D; 
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; 
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO; 
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.Timer;


public class MainPane extends JPanel implements ActionListener, KeyListener{
		private BufferedImage bg, welcome;
		private Timer time;
		private Image prompt;
		private JPanel parent;
		private CardLayout cards;
		public MainPane(JPanel parent, CardLayout cards){
			this.parent=parent;
			this.cards=cards;
			try {
				bg = ImageIO.read(new File("images/1.png"));
				welcome = ImageIO.read(new File("images/2.png"));
				ImageIcon p = new ImageIcon("images/3.gif");
				prompt = p.getImage();
				
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			this.setPreferredSize(this.getDimension());
			time = new Timer(300, this);
			this.addKeyListener(this);
			this.setFocusable(true);
		}

		@Override
		public void actionPerformed(ActionEvent arg0) {
			// TODO Auto-generated method stub
			repaint();
		}
		
		public void paint(Graphics g){
			super.paint(g);
			Graphics2D g2D = (Graphics2D)g;
			time.start();
			g2D.drawImage(bg, 0, 0, null);
			g2D.drawImage(welcome, 0, 0, null);
			g2D.drawImage(prompt, 0, 0, null);
			
		}
		
		public Dimension getDimension(){
			return new Dimension(bg.getWidth()+15, bg.getHeight()+36);
		}

		@Override
		public void keyPressed(KeyEvent k) {
			// TODO Auto-generated method stub
		
		}

		@Override
		public void keyReleased(KeyEvent k) {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void keyTyped(KeyEvent k) {
			// TODO Auto-generated method stub
			cards.show(parent, 2+"");
			
		}

		
}
